package com.nuc.edu.user.controller;

import com.nuc.edu.framework.web.controller.BaseController;
import com.nuc.edu.framework.web.page.TableDataInfo;
import com.nuc.edu.project.system.notice.domain.Notice;
import com.nuc.edu.project.system.notice.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 98217
 */
@Controller
public class UserIndexController extends BaseController {
    @Autowired
    private INoticeService noticeService;

    /**
     * 首页
     */
    @RequestMapping("user_index")
    public String index(){
        return "user_index";
    }

    /**
     * 家庭服务页面
     */
    @RequestMapping("user_service")
    public String service(){
        return "user_service";
    }

    /**
     * 企业服务页面
     */
    @RequestMapping("user_enterprise")
    public String enterprise(){
        return "user_enterprise";
    }

    /**
     * 企业合作页面
     */
    @RequestMapping("user_cooperation")
    public String cooperation(){
        return "user_cooperation";
    }

    /**
     * 关于我们页面
     */
    @RequestMapping("user_about")
    public String about(){
        return "user_about";
    }

    /**
     * 培训中心页面
     */
    @RequestMapping("user_training")
    public String training(){
        return "user_training";
    }

    /**
     * 根据新闻ID阅读新闻
     */
    @RequestMapping("user_notice/{id}")
    public String notice(Model model, @PathVariable Long id){
        Notice notice = noticeService.selectNoticeById(id);
        model.addAttribute("notice",notice);
        return "user_notice";
    }

    /**
     * 新闻列表页面
     */
    @RequestMapping("user_notice")
    public String noticeList(){
        return "user_notice_list";
    }

    /**
     * 新闻列表数据
     */
    @RequestMapping("user_notice_list")
    @ResponseBody
    public TableDataInfo list(Notice notice)
    {
        startPage();
        List<Notice> list = noticeService.selectNoticeList(notice);
        return getDataTable(list);
    }

}
